home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Files / Standard File Samples / StandardGetFolder C ƒ / StandardGetFolderMain.c < prev   
Encoding:
C/C++ Source or Header  |  1997-07-03  |  1.4 KB  |  60 lines  |  [TEXT/CWIE]

  1. #include <Quickdraw.h>
  2. #include <Fonts.h>
  3. #include <Menus.h>
  4. #include <TextEdit.h>
  5. #include <Dialogs.h>
  6. #include <Finder.h>
  7.  
  8. #include "StandardGetFolder.h"
  9.  
  10. static pascal Boolean OnlyVisibleFoldersCustomFileFilter(CInfoPBPtr myCInfoPBPtr, Ptr dataPtr)
  11. {
  12. #pragma unused (dataPtr)
  13.  
  14.     // return true if this item is invisible or a file
  15.  
  16.     Boolean visibleFlag;
  17.     Boolean folderFlag;
  18.     
  19.     visibleFlag = ! (myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible);
  20.     folderFlag = (myCInfoPBPtr->hFileInfo.ioFlAttrib & 0x10);
  21.     
  22.     // because the semantics of the filter proc are "true means don't show
  23.     // it" we need to invert the result that we return
  24.     
  25.     return !(visibleFlag && folderFlag);
  26. }
  27.  
  28.  
  29. void main(void)
  30. {
  31.     FileFilterYDUPP     invisiblesExcludedCustomFilterUPP;
  32.     StandardFileReply    mySFReply;
  33.     
  34.     // init the toolbox
  35.     
  36.     InitGraf(&qd.thePort); InitFonts(); InitWindows(); 
  37.     InitMenus(); TEInit(); InitDialogs(nil); MaxApplZone();
  38.  
  39.     // call the get folder routine, passing in our file filter
  40.     
  41.     invisiblesExcludedCustomFilterUPP = NewFileFilterYDProc(OnlyVisibleFoldersCustomFileFilter);
  42.  
  43.     StandardGetFolder(invisiblesExcludedCustomFilterUPP, &mySFReply);
  44.     
  45.     DisposeRoutineDescriptor(invisiblesExcludedCustomFilterUPP);
  46.     
  47.     // MacsBug is indeed the best UI for reporting results
  48.     /*
  49.         if (mySFReply.sfGood)
  50.         {
  51.             DebugStr(mySFReply.sfFile.name);
  52.             
  53.             if (mySFReply.sfIsVolume) DebugStr("\p is a volume");
  54.         }
  55.         else
  56.         {
  57.             DebugStr("\p cancelled");
  58.         }
  59.     */
  60. }